/*
 * Created on Aug 14, 2008
 * (c) 2009 by Reach Unlimited Corporation
 */
package com.mgmaps.maps;

import com.mgmaps.app.APPSettings;
import com.nutiteq.maps.GeoMap;
import com.nutiteq.maps.UnstreamedMap;
import com.nutiteq.maps.projections.EPSG3785;
import com.nutiteq.ui.StringCopyright;

public class OpenStreetMap extends EPSG3785 implements GeoMap, UnstreamedMap {
  
  public static final OpenStreetMap MAP = new OpenStreetMap();

  public OpenStreetMap() {
    super(new StringCopyright("OpenStreetMap"), 256, 1, 19);
    setMissingTileImage(APPSettings.missingTileImage);
  }

  public String buildPath(final int x, final int y, final int zoom) {
    final int tmpX = x >> 8;
    final int tmpY = y >> 8;
    final StringBuffer buf = new StringBuffer();
    buf.append("http://");
    buf.append((char) ('a' + (x+y)%3));
    buf.append(".tile.openstreetmap.org/");
    buf.append(zoom);
    buf.append('/');
    buf.append(tmpX);
    buf.append('/');
    buf.append(tmpY);
    buf.append(".png");
    return buf.toString();
  }
}
